package com.tommy.foreground;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * @Package Name: com.tommy.foreground
 * @Description: druid 的配置类
 * @Author tommy
 * @Date 2017.11.17 15:05
 * @Modify Who      When     What
 * ---------- ----------- -------------
 */
@Configuration
public class DruidDataSourceConfiguration {

    @Bean
    @Primary //在同样的DataSource中，首先使用被标注的DataSource
    @ConfigurationProperties(prefix = "spring.datasource.druid")
    public DataSource druidDataSource() {
        return DruidDataSourceBuilder.create().build();
    }

}
